﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tetris_data
{
    public class ShapeStruct
    {
        public ShapeStruct(Block block)
        {
            Left = 4;
            Top = 0;
            Data = block.Data;
            Width = block.Width;
            Height = block.Height;
            Color = block.Color;
        }

        public int Width { get; set; }
        public int Height { get; set; }
        public int Left { get; set; }
        public int Top { get; set; }
        public bool[,] Data { get; set; }
        public CellColor Color { get; internal set; }

        public void ChangeDirection()
        {
            if (Left + Height > 10)
            {
                return;
            }

            bool[,] temp = new bool[4,4];

            for (var row = 0; row < Height; row++)
            {
                for (var col = 0; col < Width; col++)
                {
                    temp[col,Height - 1 - row] = this.Data[row,col];
                }
            }
            int tempW = Width;
            Width = Height;
            Height = tempW;
            Data = temp;
        }

        public void MoveDown(int rows)
        {
            Top += rows;
        }

        public void MoveDown()
        {
            Top++;
        }

        public void MoveLeft()
        {
            if (Left > 0)
                Left -= 1;
        }

        public void MoveRight()
        {
            if (Left + Width < 10)
                Left += 1;
        }

        public bool Cell(int row, int col)
        {
            return Data[row,col];
        }
    }
}
